package org.javaboy.meeting.controller;

import org.javaboy.meeting.model.Meeting;
import org.javaboy.meeting.service.MeetingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class NotificationsController {
    public static final Integer CANCEL_STATUS = 1;

    @Autowired
    MeetingService meetingService;

    /**
     * 刚刚登录的时候重定向到的最新通知
     *
     * @param model
     * @return
     *
     */
    @PostMapping({"/notifications", "/admin/notifications"})
    public String notifications(Model model) {
//        System.out.println(employeeid);

//        List<Meeting> mymeetings = meetingService.getMyMeetingByEmpId(employeeid);
//        model.addAttribute("mymeetings", mymeetings);

        return "notifications";
    }

    /**
     * 之后点击最新通知的页面跳转
     * @param employeeid
     * @param model
     * @return
     */
    @RequestMapping({"/notificationsAgain", "/admin/notificationsAgain"})
    public String notificationsAgain(Integer employeeid, Model model) {
//        System.out.println(employeeid);
        List<Meeting> mymeetings = meetingService.getMyMeetingByEmpId(employeeid);
        List<Meeting> cancelMeetings = meetingService.getCancelMeetingsByStatus(CANCEL_STATUS);
        model.addAttribute("mymeetings", mymeetings);
        model.addAttribute("cancelMeetings",cancelMeetings);
        return "notificationsAgain";
    }
}
